
<?php
/* exibindo o browser do usuario */
echo $_SERVER["HTTP_USER_AGENT"]; ?></div>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Atualizar Produto</title>
<?php include "menu.inc"?>

</head>
<body>
<!-- ************************************************************************ -->
<!-- Tela Produto -->
<br />
<br />

<form name="form" method="post" action="../negocio/Ecommerce.php"><input
	type="hidden" name="operacao" value="atualizarp"></input>
<table border="0" cellpadding="2" cellspacing="1" align="center">
	<td bgcolor="#0099FF" colspan="2" align="center">Atualizar de Produto</td>

	<?php

	include_once '../negocio/Conexao.php';
	$nome = $_POST['nome'];

	try {
		if($nome != null){
			$conexao = new Conexao();
			$sql = $conexao->prepare("SELECT p.nome, p.preco, p.descricao,i.conteudo FROM produto as p inner join imagem as i on 
			p.id_imagem = i.id where p.nome = ?");
			$sql->bindValue(1, $nome);
			$sql->execute();
			$res = $sql->fetchObject();
			if($res != null){
				?>
	<tr>
		<td>Nome :</td>
		<td><input type="text" name="nome" value="<?php echo $res->nome?>" />
		</td>
	</tr>

	<tr>
		<td>Preco :</td>
		<td><input type="text" name="preco" value="<?php echo $res->preco?>" /></td>
	</tr>

	<tr>
		<td>Descricao :</td>
		<td><input type="text" name="descricao"
			value="<?php echo $res->descricao?>" /></td>
	</tr>

	<tr >
		<td>Imagem :</td>
		<td><?php echo '<img src="'.$res->conteudo.'" width="100" heigth="100"/>'.'<br>';?></td>
	</tr>

	<tr></tr>
	<tr></tr>
	<tr></tr>
	
	<tr>
		<td align="center" colspan="2"><input type="submit" name="Atualizar"
			value="Atualizar Produto" /></td>
	</tr>

	<?php
			}
		}else
		{
			echo "<center><i>Escolha um produto e digite o nome!</i></center>";
		}

	} catch (PDOException $pdo) {
		throw new ErrorBanco($pdo->getMessage(), $pdo->getCode());
	}

	?>

</table>
</form>
</body>
</html>
